﻿(function ($) {
    $.extend({
        Pagination: function (options) {
            var defaultOption = {
                pagination: "",
                href: window.location.pathname,
                form: "",
                extendData: {},
                submit: function (page, o) {
                    var data = { page };
                    if (o.extendData) {
                        data = $.extend(true, data, o.extendData);
                    }

                    data = $.param(data);

                    if ($(o.form).length > 0) {
                        data += "&" + $(o.form).seriliaze();
                    }

                    window.location.href = o.href + '?' + data;
                }
            }

            var o = $.extend(true, defaultOption, options);

            $(o.pagination).find("[data-page]").click(function (item) {
                var page = $(this).attr("data-page") - 0;
                o.submit(page, o);
            })
        }
    })
})(jQuery)